package com.seelyn.dowork.repositories;

import com.seelyn.dowork.entities.Course;
import com.seelyn.dowork.entities.CourseExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

public interface CourseMapper {
    @SelectProvider(type=CourseSqlProvider.class, method="countByExample")
    long countByExample(CourseExample example);

    @DeleteProvider(type=CourseSqlProvider.class, method="deleteByExample")
    int deleteByExample(CourseExample example);

    @Delete({
        "delete from st_course",
        "where course_id = #{courseId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long courseId);

    @Insert({
        "insert into st_course (course_id, created_on, ",
        "del_flag, updated_on, ",
        "audit_flag, duration, ",
        "end_date, star, start_date, ",
        "title, category_id, ",
        "attending, instructor_id, ",
        "content)",
        "values (#{courseId,jdbcType=BIGINT}, #{createdOn,jdbcType=TIMESTAMP}, ",
        "#{delFlag,jdbcType=VARCHAR}, #{updatedOn,jdbcType=TIMESTAMP}, ",
        "#{auditFlag,jdbcType=VARCHAR}, #{duration,jdbcType=INTEGER}, ",
        "#{endDate,jdbcType=TIMESTAMP}, #{star,jdbcType=REAL}, #{startDate,jdbcType=TIMESTAMP}, ",
        "#{title,jdbcType=VARCHAR}, #{categoryId,jdbcType=BIGINT}, ",
        "#{attending,jdbcType=INTEGER}, #{instructorId,jdbcType=BIGINT}, ",
        "#{content,jdbcType=LONGVARCHAR})"
    })
    int insert(Course record);

    @InsertProvider(type=CourseSqlProvider.class, method="insertSelective")
    int insertSelective(Course record);

    @SelectProvider(type=CourseSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="course_id", property="courseId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="audit_flag", property="auditFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="duration", property="duration", jdbcType=JdbcType.INTEGER),
        @Result(column="end_date", property="endDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="star", property="star", jdbcType=JdbcType.REAL),
        @Result(column="start_date", property="startDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="category_id", property="categoryId", jdbcType=JdbcType.BIGINT),
        @Result(column="attending", property="attending", jdbcType=JdbcType.INTEGER),
        @Result(column="instructor_id", property="instructorId", jdbcType=JdbcType.BIGINT),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Course> selectByExampleWithBLOBsWithRowbounds(CourseExample example, RowBounds rowBounds);

    @SelectProvider(type=CourseSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="course_id", property="courseId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="audit_flag", property="auditFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="duration", property="duration", jdbcType=JdbcType.INTEGER),
        @Result(column="end_date", property="endDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="star", property="star", jdbcType=JdbcType.REAL),
        @Result(column="start_date", property="startDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="category_id", property="categoryId", jdbcType=JdbcType.BIGINT),
        @Result(column="attending", property="attending", jdbcType=JdbcType.INTEGER),
        @Result(column="instructor_id", property="instructorId", jdbcType=JdbcType.BIGINT),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Course> selectByExampleWithBLOBs(CourseExample example);

    @SelectProvider(type=CourseSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="course_id", property="courseId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="audit_flag", property="auditFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="duration", property="duration", jdbcType=JdbcType.INTEGER),
        @Result(column="end_date", property="endDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="star", property="star", jdbcType=JdbcType.REAL),
        @Result(column="start_date", property="startDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="category_id", property="categoryId", jdbcType=JdbcType.BIGINT),
        @Result(column="attending", property="attending", jdbcType=JdbcType.INTEGER),
        @Result(column="instructor_id", property="instructorId", jdbcType=JdbcType.BIGINT)
    })
    List<Course> selectByExampleWithRowbounds(CourseExample example, RowBounds rowBounds);

    @SelectProvider(type=CourseSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="course_id", property="courseId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="audit_flag", property="auditFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="duration", property="duration", jdbcType=JdbcType.INTEGER),
        @Result(column="end_date", property="endDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="star", property="star", jdbcType=JdbcType.REAL),
        @Result(column="start_date", property="startDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="category_id", property="categoryId", jdbcType=JdbcType.BIGINT),
        @Result(column="attending", property="attending", jdbcType=JdbcType.INTEGER),
        @Result(column="instructor_id", property="instructorId", jdbcType=JdbcType.BIGINT)
    })
    List<Course> selectByExample(CourseExample example);

    @Select({
        "select",
        "course_id, created_on, del_flag, updated_on, audit_flag, duration, end_date, ",
        "star, start_date, title, category_id, attending, instructor_id, content",
        "from st_course",
        "where course_id = #{courseId,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="course_id", property="courseId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="audit_flag", property="auditFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="duration", property="duration", jdbcType=JdbcType.INTEGER),
        @Result(column="end_date", property="endDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="star", property="star", jdbcType=JdbcType.REAL),
        @Result(column="start_date", property="startDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="category_id", property="categoryId", jdbcType=JdbcType.BIGINT),
        @Result(column="attending", property="attending", jdbcType=JdbcType.INTEGER),
        @Result(column="instructor_id", property="instructorId", jdbcType=JdbcType.BIGINT),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    Course selectByPrimaryKey(Long courseId);

    @UpdateProvider(type=CourseSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Course record, @Param("example") CourseExample example);

    @UpdateProvider(type=CourseSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Course record, @Param("example") CourseExample example);

    @UpdateProvider(type=CourseSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Course record, @Param("example") CourseExample example);

    @UpdateProvider(type=CourseSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Course record);

    @Update({
        "update st_course",
        "set created_on = #{createdOn,jdbcType=TIMESTAMP},",
          "del_flag = #{delFlag,jdbcType=VARCHAR},",
          "updated_on = #{updatedOn,jdbcType=TIMESTAMP},",
          "audit_flag = #{auditFlag,jdbcType=VARCHAR},",
          "duration = #{duration,jdbcType=INTEGER},",
          "end_date = #{endDate,jdbcType=TIMESTAMP},",
          "star = #{star,jdbcType=REAL},",
          "start_date = #{startDate,jdbcType=TIMESTAMP},",
          "title = #{title,jdbcType=VARCHAR},",
          "category_id = #{categoryId,jdbcType=BIGINT},",
          "attending = #{attending,jdbcType=INTEGER},",
          "instructor_id = #{instructorId,jdbcType=BIGINT},",
          "content = #{content,jdbcType=LONGVARCHAR}",
        "where course_id = #{courseId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKeyWithBLOBs(Course record);

    @Update({
        "update st_course",
        "set created_on = #{createdOn,jdbcType=TIMESTAMP},",
          "del_flag = #{delFlag,jdbcType=VARCHAR},",
          "updated_on = #{updatedOn,jdbcType=TIMESTAMP},",
          "audit_flag = #{auditFlag,jdbcType=VARCHAR},",
          "duration = #{duration,jdbcType=INTEGER},",
          "end_date = #{endDate,jdbcType=TIMESTAMP},",
          "star = #{star,jdbcType=REAL},",
          "start_date = #{startDate,jdbcType=TIMESTAMP},",
          "title = #{title,jdbcType=VARCHAR},",
          "category_id = #{categoryId,jdbcType=BIGINT},",
          "attending = #{attending,jdbcType=INTEGER},",
          "instructor_id = #{instructorId,jdbcType=BIGINT}",
        "where course_id = #{courseId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Course record);
}